$(function(){

	
	var idnum = window.location.href;
	var start = idnum.indexOf("categoryId=");
	var categoryId = idnum.substring(start+11);

	loadPicInfo();

	function loadPicInfo(){
		if (start==-1) {
		categoryId = "0";
		}
		//获取全部图片信息
		$.ajax({
		    async: false,
			cache:false,
			type: 'POST',
			url: "picInfoAction_getpicInfo.action",
			data: {
				categoryId:categoryId
			}, 
			dataType:"json",
			success: function (data) {
				if(data.list!=null){

					$.each(data.list, function (index, item) {
			            //循环获取数据    
			            var id = (data.list)[index].id;
			            var title = (data.list)[index].title + "（"+(data.list)[index].categoryNameCN+"）";
			            var src = (data.list)[index].src0;
			            $("#fh5co-projects-feed").append("<div class='fh5co-project masonry-brick'>"
						+"<a href='single.html?id="+ id +"' id='"+id+"' onclick= 'putID("+ id +")'>"
						+	"<img src='" + src + "' width='100%' height='100%' alt='"+ title+ "'>"
						+	"<h2>"+ title + "</h2>"
						+"</a>"
					+"</div>");
			        }); 
				}
			},
		    error: function () {
		      alert("出现异常！！");
			}
		});
	}

	//获取分类信息
	$.ajax({
	    async: false,
		cache:false,
		type: 'POST',
		url: "picCategoryAction_getpicCategory.action",
		/* data{
			code:code
		}, */
		dataType:"json",
		success: function (data) {
			if(data.list!=null){
				$.each(data.list, function (index, item) {  
		            //循环获取数据    
		            var id = (data.list)[index].categoryId;
		            var categoryName = (data.list)[index].categoryName;
		            $("#fh5co-menu-ul").append("<li id='"+ id + "'>" + categoryName +"</li>");
		        }); 
			}
		},
		error: function () {
		      alert("出现异常！！");
		}
	});

	$(".moreli").mouseenter(function(){
	$(this).children("div").children("ul").stop(true);
    // $(this).children("div").fadeIn(300);
    $(this).children("div").children("ul").fadeIn(300);
	});
	$(".moreli").mouseleave(function(){
   // $(this).children("div").fadeOut(300);
	$(this).children("div").children("ul").fadeOut(300);
	});

	$("#fh5co-menu-ul").on("click","li",function(){      //只需要找到你点击的是哪个ul里面的就行
		var id=$(this).attr("id");
		if (id==0) {
			window.location.href="//www.mrhaha-dw.com";
		}
		else{
			categoryId = id;
			// $("#fh5co-projects-feed").empty();
			// document.getElementById('fh5co-projects-feed').innerHTML = '';
			// document.getElementById('fh5co-projects-feed').parentNode.removeChild();
			// $("#container-fluid").empty();
			// document.getElementById('picInfo').innerHTML = '';
			// $("#picInfo").append("<div id='container-fluid' class='container-fluid pt70 pb70'><div id='fh5co-projects-feed' class='fh5co-projects-feed clearfix masonry'>"+"</div></div>");
			// loadPicInfo();
			window.location.href="//www.mrhaha-dw.com?categoryId="+id;
		}
 	});

})
